﻿
/**
*@description 个人密码修改表单，个人密码初始化表单
*/
Chenxin.UI.PersonalPwdChange=Chenxin.extend(Chenxin.UI.FormCommon,{	
	actionUrl:'/service/PersonalCenter.ashx',
	id:'ppcchange',
	renderTo:'ppcchangeWin',
	jqmWidth:420,
	defBBtn:true,
	createForm:function(){
		return Chenxin.FormCommon.personalPwdChange(this.id);
	},
	afterGetFormJson:function(model){
		Chenxin.apply(this.additionalParam,model);
	},
	customerFormVal:function(model){
		if(!model.newpwd){
			alert('请输入新密码！');
			return false;
		}
		return true;
	},
	handleLogin:function(){		
		var userid=Chenxin.Fn.getQueryString('userid');
		if(userid){
			Chenxin.ajax({
				url:this.actionUrl,
				type:'get',
				data:{op:'handlelogin',userid:userid},
				onSuccess:function(data,msg){
					window.location.href='PersonalCenter.aspx';
				}
			});		
		}
	},
	createNewPwd:function(){
		var _this=this;
		Chenxin.ajax({
			url:this.actionUrl,
			type:'get',
			async:false,
			data:{op:'createnewpassword'},
			onSuccess:function(data,msg){
				_this.findByName('newpwd').val(data.newpwd);
			}
		});
	},
	initFormValidator:function(){
		var _this=this;
		var filter='#'+this.id;
		$(filter+'_oldpassword').formValidator({
			validatorgroup:this.id,
            onshow: "请输入原密码!", 
			onfocus: "请输入原密码!", 
			oncorrect: " "
        }).inputValidator({ //非空验证
            min: 1, 
			empty: { 
				leftempty: false, 
				rightempty: false, 
				emptyerror: "原密码不能为空!" 
			}, 
			onerror: "原密码不能为空!"
        })
		
	},
	initEvent:function(){	
		var _this=this;
		var filter='#'+this.id;
		$(filter+'_Save').live('click',function(){			
			_this.save();
		});
		$(filter+'_Cancle').live('click',function(){
			_this.hide();			
		});	
		$(filter+'_CreateNewPwd').live('click',function(){
			_this.op='changepwd';
			_this.createNewPwd();			
		});	
		
	},
	initComponent:function(){
		Chenxin.UI.PersonalPwdChange.superclass.initComponent.call(this);
	}
});


Chenxin.FormCommon.personalPwdChange=function(comboIdPrefix){
	return '<table class="tbl_f"><tr><th style="width:80px;">原密码：</th><td><input id="' + comboIdPrefix + '_oldpassword" name="oldpwd" class="inputbox_n fl" type="text"  style="width:160px;" /><div id="' + comboIdPrefix + '_oldpasswordTip" style="float: left; margin-left: 5px; width: 90; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><th>新密码：</th><td><input readonly="readonly" name="newpwd" class="inputbox_n fl" type="text"  style="width:160px;" /><input type="button" style="margin-left:5px;" value="生成新密码" id="'+comboIdPrefix+'_CreateNewPwd"/></td></tr><tr><td colspan="2" align="right"><div style="float:right; margin-right:15px;"><a id="' + comboIdPrefix + '_Save" class="btn_n fl" href="#"><span>确定</span></a><a id="' + comboIdPrefix + '_Cancle"  class="btn_n fl" href="#"><span>取消</span></a></div></td></tr></table>';
};